//
//  ZYCTeaLeaveRecordApproveBottomView.m
//  ZDSC
//
//  Created by 张威 on 2021/10/21.
//

#import "ZYCTeaLeaveRecordApproveBottomView.h"
#import "UIView+Gt.h"

@interface ZYCTeaLeaveRecordApproveBottomView ()

@property (nonatomic, strong) UIButton *refuseButton;
@property (nonatomic, strong) UIButton *passButton;
@end
@implementation ZYCTeaLeaveRecordApproveBottomView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {

        [self addSubview:self.refuseButton];
        [self addSubview:self.passButton];
        [self.refuseButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.bottom.equalTo(self);
            make.width.mas_equalTo(self.width / 2);
        }];
        
        [self.passButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.top.bottom.equalTo(self);
            make.width.mas_equalTo(self.width / 2);
        }];
        
        self.type = ZYCTeaLeaveApproveBottomTypeReject;
 
    }
    return self;
}

- (UIButton *)refuseButton {
    if (!_refuseButton) {
        _refuseButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _refuseButton.frame = CGRectMake(0,0, kScreenWidth - 2 * 66, 40);
        _refuseButton.tag = 1000;
        [_refuseButton setTitle:@"拒绝" forState:UIControlStateNormal];
        [_refuseButton setTitleColor:HEX_RGB(kTitleWhiteColor) forState:UIControlStateNormal];
        _refuseButton.backgroundColor = HEX_RGB(@"#E93C06");
        _refuseButton.titleLabel.font = kCustomFont(@"PingFangSC-Regular", 15.0f);
        [_refuseButton addTarget:self action:@selector(clickComfirmAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _refuseButton;
}

- (UIButton *)passButton {
    if (!_passButton) {
        _passButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _passButton.frame = CGRectMake(0,0, kScreenWidth - 2 * 66, 40);
        _passButton.tag = 1001;
        [_passButton setTitle:@"同意" forState:UIControlStateNormal];
        [_passButton setTitleColor:HEX_RGB(kTitleWhiteColor) forState:UIControlStateNormal];
        _passButton.backgroundColor = HEX_RGB(@"#41B166");
        _passButton.titleLabel.font = kCustomFont(@"PingFangSC-Regular", 15.0f);
        [_passButton addTarget:self action:@selector(clickComfirmAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _passButton;
}

-(void)clickComfirmAction:(UIButton *)sender{
    
    if (sender.tag == 1000) {
        self.type = ZYCTeaLeaveApproveBottomTypeReject;
    }else{
        self.type = ZYCTeaLeaveApproveBottomTypePass;
    }
    
    if ([self.delegate respondsToSelector:@selector(teaLeaveRecordApproveBottomViewClick:)]) {
        [self.delegate teaLeaveRecordApproveBottomViewClick:self.type];
    }
}

@end
